using System;
using System.Collections.Generic;
using System.Text;

namespace GoogleNet
{
    /// <summary>
    /// <para>
    /// Once you have positioned the camera in space and oriented it, 
    /// you need to define how much of the current scene is visible. 
    /// Specifying the field of view is analogous to specifying the 
    /// lens opening in a physical camera. A small field of view, like a 
    /// telephoto lens, focuses on a small part of the scene. 
    /// A large field of view, like a wide-angle lens, focuses on a large part of the scene.
    /// </para>
    /// <para>
    /// The field of view for a PhotoOverlay is defined by four planes, each of which is 
    /// specified by an angle relative to the view vector. These four planes define the 
    /// top, bottom, left, and right sides of the field of view, which has the shape of a truncated pyramid.
    /// </para>
    /// </summary>
    public class KmlViewVolume : IKmlElement
    {
        private string tagName = "ViewVolume";

        #region Distance
        private int distance;

        /// <summary>
        /// Measurement in meters along the viewing direction from 
        /// the camera viewpoint to the PhotoOverlay shape.
        /// </summary>
        /// <value>The distance.</value>
        public int Distance
        {
            get { return distance; }
            set { distance = value; }
        } 
        #endregion

        #region LeftFov
        private double leftFov;

        /// <summary>
        /// Angle, in degrees, between the camera's viewing direction and the left side of the view volume.
        /// </summary>
        /// <value>The left fov.</value>
        public double LeftFov
        {
            get { return leftFov; }
            set { leftFov = value; }
        } 
        #endregion

        #region RightFov
        private double rightFov;

        /// <summary>
        /// Angle, in degrees, between the camera's viewing direction and the right side of the view volume.
        /// </summary>
        /// <value>The right fov.</value>
        public double RightFov
        {
            get { return rightFov; }
            set { rightFov = value; }
        }
        #endregion

        #region TopFov
        private double topFov;

        /// <summary>
        /// Angle, in degrees, between the camera's viewing direction and the top side of the view volume.
        /// </summary>
        /// <value>The top fov.</value>
        public double TopFov
        {
            get { return topFov; }
            set { topFov = value; }
        }
        #endregion

        #region BottomFov
        private double bottomFov;

        /// <summary>
        /// Angle, in degrees, between the camera's viewing direction and the bottom side of the view volume.
        /// </summary>
        /// <value>The bottom fov.</value>
        public double BottomFov
        {
            get { return bottomFov; }
            set { bottomFov = value; }
        }
        #endregion

        #region IKmlElement Members

        /// <summary>
        /// Name of the KML tag for this specific element.
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        public string TagName
        {
            get { return tagName; }
        }

        #endregion

        #region IKmlGenerator Members

        /// <summary>
        /// Generates the KML for this element including its child elements.
        /// </summary>
        /// <param name="writer">The XML writer that will be used to generate the KML.</param>
        public void GenerateKml(System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement(tagName);

            writer.WriteElementString("distance", distance.ToString());
            writer.WriteElementString("leftFov", leftFov.ToString());
            writer.WriteElementString("rightFov", rightFov.ToString());
            writer.WriteElementString("topFov", topFov.ToString());
            writer.WriteElementString("bottomFov", bottomFov.ToString());         

            writer.WriteFullEndElement();
        }

        #endregion
    }
}
